package com.chatify.app;


import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class UserListAdapter extends BaseAdapter {
  private final Context context;
  
  private List<UserDetail> userList;
  public UserListAdapter(Context context, List<UserDetail> userList) {
	
    this.context = context;
    this.userList = userList;
  }
  public int getCount() {
      return userList.size();
  }

  public Object getItem(int position) {
      return position;
  }

  public long getItemId(int position) {
      return position;
  }
  public View getView(int position, View convertView, ViewGroup parent) {
	  if (convertView == null) {
	        // This a new view we inflate the new layout
	        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	        convertView = inflater.inflate(R.layout.user_row, parent, false);
	    
    
    TextView textName = (TextView) convertView.findViewById(R.id.name);
    TextView textPresense = (TextView) convertView.findViewById(R.id.presense);
   // ImageView imgDisplay = (ImageView) convertView.findViewById(R.id.imgdisplay);
    UserDetail item = userList.get(position);
    
    textName.setText(item.Name);
    textPresense.setText(item.Presence);
    //imgDisplay.setImageBitmap(item.Image);
	  }
    return convertView;
  }
} 